var e = require;
var t = module;
cc.Class({
    extends: cc.Component,
    properties: {labelContent: cc.Label, nodeLocked: cc.Node, bg: cc.Node},
    start: function start() {
        (this.bgColor = ["#000000", "#EAD51E", "#1C436F", "#1EDEEA"]), (this.lvIndex = this.getIndexFromParent());
        var e = lGlobal.model || lGlobal.MODEL_CUSTOM,
            t = lGlobal.userData.levelState[e][this.lvIndex] || 0;
        (this.nodeLocked.active = 0 == t), (this.bg.color = this.bg.color.fromHEX(this.bgColor[t]));
        var o = null,
            n = lGlobal.lvCfg.json[lGlobal.model][this.lvIndex].model;
        if (n) {
            var i = lGlobal.lvCfg.json[lGlobal.model][this.lvIndex].modelIndex;
            o = lGlobal.lvCfg.json[n][i].name;
        } else o = lGlobal.lvCfg.json[lGlobal.model][this.lvIndex].name;
        this.labelContent.string = o || "关卡" + (this.lvIndex + 1);
    },
    onSelfClick: function onSelfClick() {
        var e = this;
        this.nodeLocked.active
            ? lplatform.showRewardedVideo(function (t) {
                  if (t) {
                      var o = lGlobal.model || lGlobal.MODEL_CUSTOM;
                      (lGlobal.userData.levelState[o][e.lvIndex] = 1),
                          lGlobal.saveUserData(),
                          lGlobal.loadLevel(void 0, e.lvIndex);
                  }
              })
            : lGlobal.loadLevel(void 0, this.lvIndex),
            soundMgr.playSound(soundMgr.btn);
    },
    getIndexFromParent: function getIndexFromParent() {
        for (var e = -1, t = 0; t < this.node.parent._children.length; t++) {
            if (this.node.parent._children[t] == this.node) {
                e = t;
                break;
            }
        }
        return e;
    },
    setNowMode: function setNowMode(e) {
        this.lvMode = e;
    }
});
